import java.util.Arrays;

public class Test {

    public static void func(){
        int[] array1 = new int[3];
        array1[0] = 10;
        array1[1] = 20;
        array1[2] = 30;

        int[] array2 = new int[]{1,2,3,4,5};
        array2[0] = 100;
        array2[1] = 200;

        array1 = array2;
        array1[2] = 300;
        array1[3] = 400;
        array2[4] = 500;
        for (int i = 0; i < array2.length; i++) {
            System.out.println(array2[i]);
        }
    }

    public static void main3(String[] args) {
        int[] array1 = {1,2,3,4,5};
        /*for (int i = 0; i < array1.length; i++) {
            System.out.print(array1[i] + " ");
        }
        System.out.println();*/

        /*for(int x : array1){
            System.out.print(x + " ");
        }
        System.out.println();*/

        String ret = Arrays.toString(array1);
        System.out.println(ret);
    }

    public static void main2(String[] args) {
        int[] array1;
        array1 = new int[10];

        int[] array2;
        array2 = new int[]{1,2,3,4,5};

        // 只有在定义的时候同时初始化才可以,否则编译器会报错
        /*int[] array3;
        array3 = {1,2,3,4,5,6,7,8,9,10};*/
    }

    public static void main1(String[] args) {
        int[] array1 = new int[5];
        double[] array2 = new double[5];
        String[] array3 = new String[5];

    }
}
